<?php
class keu_tipe_jurnal_coa_model extends MY_Model {
	var $model = 'keu_tipe_jurnal_coa';
	
	function GetJSON()
	{
		$ls_sql	= "	SELECT	TD.*, COA.NAMA_COA, CC.NAMA_COST_CENTER
					FROM	KEU_TIPE_JURNAL_COA TD
							LEFT JOIN KEU_COA COA ON COA.ID_COA = TD.ID_COA
							LEFT JOIN SW_COST_CENTER CC ON TD.KD_COST_CENTER = CC.ID_COST_CENTER_PK
					WHERE	
							TD.KD_TIPE_JURNAL = '".post('kd_tipe_jurnal')."'
					ORDER BY ".(post('sort')=='' ? 'TD.NO_URUT' : post('sort'))." ".(post('order')=='' ? 'asc' : post('order'));
					
		return json_encode( $this->paging($ls_sql) );
	}
		
	function Add($arr_data){
		$this->db->insert('KEU_TIPE_JURNAL_COA', $arr_data);
	}
	
	function Update($arr_data, $arr_new_data){
		$this->db->update('KEU_TIPE_JURNAL_COA', $arr_data, $arr_new_data);
	}
	
	
	function DeleteSingle($as_tipe_jurnal, $as_coa)
	{
		try {
			$this->db->delete('KEU_TIPE_JURNAL_COA', array('kd_tipe_jurnal' => $as_tipe_jurnal, 'id_coa' => $as_coa));
			return '';
		} catch(Exception $e) {
			return $e->getMessage();
		}
	}
}
?>